package com.cityeye.dao;

import org.hibernate.criterion.Order;

import com.cityeye.entity.Department;
import com.cityeye.entity.Patrol;
import com.cityeye.entity.Subissuetype;
import com.cityeye.search.SearchCriteria;

public class PatrolDao extends AbstractEntityDao<Patrol> {

	private static SearchCriteria[] criteria;

	public Patrol createNewEmptyEntity() {
		return new Patrol();
	}

	protected Object evalueateProperty(String key, Object valueObj) {
		String idStr = valueObj.toString();

		if (key.equalsIgnoreCase("department")) {
			return sf.getCurrentSession().get(Department.class,
					Integer.parseInt(idStr));
		}

		return valueObj;
	}

	public SearchCriteria[] getSearchCriteria() {
		if (criteria == null) {
			criteria = new SearchCriteria[] {
					new SearchCriteria("Code", SearchCriteria.VT_INT),
					new SearchCriteria("Name", SearchCriteria.VT_STRING),
					new SearchCriteria("Taxable", SearchCriteria.VT_STRING),
					new SearchCriteria("Mobile", SearchCriteria.VT_STRING) };
		}
		return criteria;
	}

	protected Class<Patrol> getEntityClass() {
		return Patrol.class;
	}

	protected Order getOrderField() {
		return Order.asc("name");
	}
}
